package ku.report.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import ku.report.dto.WeekReportDTO;
import ku.report.ibatis.SqlDaoSuport;
import ku.report.idao.IWeekReportDAO;

public class WeekReportDAO extends SqlDaoSuport implements IWeekReportDAO{

	public WeekReportDAO() {
		super();
	}

	public WeekReportDAO(String path) {
		super(path);
	}

	@Override
	public List<WeekReportDTO> WeekReportList() {
		List<WeekReportDTO> wlist = null;
		try {
			wlist = (List<WeekReportDTO>)this.getSqlMapper().queryForList("wlist");
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : WeekReportList === " + e);
		}
		return wlist;
	}
	
	@Override
	public int submitReport(WeekReportDTO wdto) {
		int addcheck = 0;
		try {
			this.getSqlMapper().insert("submitReport", wdto);
			addcheck++;
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : submitReport === " + e);
		}
		return addcheck;
	}

	@Override
	public WeekReportDTO showWeekDetail(int wseq) {
		WeekReportDTO wdto = new WeekReportDTO();
		try {
			wdto = (WeekReportDTO) this.getSqlMapper().queryForObject("showWeekDetail", wseq);
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : showWeekDetail === " + e);
		}
		return wdto;
	}

	@Override
	public int doUpdate(WeekReportDTO wdto) {
		int check = 0;
		try {
			this.getSqlMapper().update("doUpdate", wdto);
			check++;
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : doUpdate === " + e);
		}
		return check;
	}

	@Override
	public int doDelete(int wseq) {
		int check = 0;
		try {
			this.getSqlMapper().delete("doDelete", wseq);
			check++;
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : doDelete === " + e);
		}
		return check;
	}

	@Override
	public int pmCheck(WeekReportDTO wdto) {
		int check = 0;
		try {
			this.getSqlMapper().queryForObject("pmCheck", wdto);
			check++;
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : pmCheck === " + e);
		}
		return check;
	}

	@Override
	public List<WeekReportDTO> getAllWeekReport(String weeknum) {
		List<WeekReportDTO> wdto = null;
		try {
			wdto = (List<WeekReportDTO>)this.getSqlMapper().queryForList("getAllWeekReport", weeknum);
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : getAllWeekReport === " + e);
		}
		return wdto;
	}

	@Override
	public List<WeekReportDTO> weekTotalReportList() {
		List<WeekReportDTO> wlist = null;
		try {
			wlist = (List<WeekReportDTO>)this.getSqlMapper().queryForList("weekTotalReportList");
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : weekTotalReportList === " + e);
		}
		return wlist;
	}

	@Override
	public int submitWtotalReport(WeekReportDTO wdto) {
		int addcheck = 0;
		try {
			this.getSqlMapper().insert("submitWtotalReport", wdto);
			addcheck++;
		} catch (SQLException e) {
			System.out.println("WeekReportDAO : submitWtotalReport === " + e);
		}
		return addcheck;
	}
}
